package fractales.algo;

import java.awt.Graphics2D;
import java.awt.geom.Point2D;

import fractales.ui.FractaleUI;


public class CourbeDeKoch extends Fractale
{
	private static final double _60_DEGRES = Math.PI/3;
	
	protected void recurse(Graphics2D g, double x1, double y1, double x2, double y2, double length, double angle, int iteration)
	{
		double newLength = length / 3.0;
		
		Point2D p1 = drawLine(g, x1, y1, newLength, angle, iteration);
		Point2D p2 = drawLine(g, p1.getX(), p1.getY(), newLength, angle-_60_DEGRES, iteration);
		Point2D p3 = drawLine(g, p2.getX(), p2.getY(), newLength, angle+_60_DEGRES, iteration);
		drawLine(g, p3.getX(), p3.getY(), x2, y2, newLength, angle, iteration);
	}

	public static void main (String[] args)
	{
		CourbeDeKoch p = new CourbeDeKoch();
    	FractaleUI.display(p);
	}
}
